<%@ Page AutoEventWireup="true" CodeBehind="FolderViewer.aspx.cs" Inherits="Dascoba.Umb.FileManager.Pages.FolderViewer"
    Language="C#" MasterPageFile="../../masterpages/umbracoPage.Master" ValidateRequest="false" %>

<%@ Register Assembly="controls" Namespace="umbraco.uicontrols" TagPrefix="cc1" %>
<asp:Content ContentPlaceHolderID="head" ID="headContent" runat="server">
    <link href="../js/jeegoocontext/skins/cm_default/style.css" rel="stylesheet" type="text/css" />
    <link href="../../css/umbContext.css" type="text/css" rel="stylesheet" />
    <script src="../js/jeegoocontext/jquery.jeegoocontext.min.js" type="text/javascript"></script>
    <script type="text/javascript">

        var actionComplete = 1;

        $(window).load(function () {
            resizecontent();
        });

        $(window).resize(function () {
            resizecontent();
        });

        $(window).focus(function () {
            if (actionComplete == 0) {
                window.location.href = window.location.href;
                actionComplete = 1;
            }
        });

        function resizecontent() {
            var contentHeight = $(window).height() - 120;
            $('#<%=panel_foldercontent.ClientID %>').height(contentHeight);
            $('.tabpagescrollinglayer').css('overflow', 'hidden');
        }

        function setNodeId(item) {
            parent.nodeID = $(item).find('input.itemUrl').val(); return true;
        }

        $(function () {
            $('.umbracoFolder').jeegoocontext('umbracoMenu', {
                widthOverflowOffset: 0,
                heightOverflowOffset: 3,
                submenuLeftOffset: -4,
                submenuTopOffset: -5,
                onShow: function (e, context) { setNodeId(context); },
                onSelect: function (e, context) { takeAction(this); }
            });
        });

        $(function () {
            $('.folderEmpty').jeegoocontext('folderEmptyMenu', {
                widthOverflowOffset: 0,
                heightOverflowOffset: 3,
                submenuLeftOffset: -4,
                submenuTopOffset: -5,
                onShow: function (e, context) { setNodeId(context); },
                onSelect: function (e, context) { takeAction(this); }
            });
        });

        $(function () {
            $('.folder').jeegoocontext('folderMenu', {
                widthOverflowOffset: 0,
                heightOverflowOffset: 3,
                submenuLeftOffset: -4,
                submenuTopOffset: -5.,
                onShow: function (e, context) { setNodeId(context); },
                onSelect: function (e, context) { takeAction(this); }
            });
        });

        $(function () {
            $('.file').jeegoocontext('fileMenu', {
                widthOverflowOffset: 0,
                heightOverflowOffset: 3,
                submenuLeftOffset: -4,
                submenuTopOffset: -5,
                onShow: function (e, context) { setNodeId(context); },
                onSelect: function (e, context) { takeAction(this); }
            });
        });

        $(function () {
            $('.archiveFile').jeegoocontext('archiveFileMenu', {
                widthOverflowOffset: 0,
                heightOverflowOffset: 3,
                submenuLeftOffset: -4,
                submenuTopOffset: -5,
                onShow: function (e, context) { setNodeId(context); },
                onSelect: function (e, context) { takeAction(this); }
            });
        });

        $(function () {
            $('.currentFolder').jeegoocontext('currentFolderMenu', {
                widthOverflowOffset: 0,
                heightOverflowOffset: 3,
                submenuLeftOffset: -4,
                submenuTopOffset: -5,
                onShow: function (e, context) { parent.nodeID = '<%=Request["folder"] %>'; },
                onSelect: function (e, context) { takeAction(this); }
            });
        });

        $(function () {
            $('.rootFolder').jeegoocontext('rootFolderMenu', {
                widthOverflowOffset: 0,
                heightOverflowOffset: 3,
                submenuLeftOffset: -4,
                submenuTopOffset: -5,
                onShow: function (e, context) { parent.nodeID = 'root'; },
                onSelect: function (e, context) { takeAction(this); }
            });
        });

    </script>
</asp:Content>
<asp:Content ContentPlaceHolderID="body" ID="bodyContent" runat="server">
    <cc1:TabView ID="tabs_foldercontent" runat="server" />
    <cc1:Pane ID="pane_foldercontent" runat="server">
        <asp:Panel ID="panel_foldercontent" style="overflow:auto;width:100%;height:100%;" runat="server" BackColor="White" 
            BorderStyle="Inset" BorderWidth="1px" ScrollBars="Auto">
            <asp:Repeater ID="contentRepeater" runat="server">
            </asp:Repeater>
        </asp:Panel>
    </cc1:Pane>
</asp:Content>
<asp:Content ContentPlaceHolderID="footer" ID="footerContent" runat="server">
    <!-- Context Menus -->
    <%=this.ContextMenus %>
    <!-- End Context Menus -->
</asp:Content>
